<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>历史欠费信息录入</title>
<LINK href="images/css.css" type="text/css" rel="stylesheet">
<script language="javascript">
	var req;
	
	function init() {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	//根据房产编号查询DropChangeAJAXAction，判断该房产是否存在
	function findHouseByHouseId() {
		init();
		var url="dropChangeAJAX.do?method=findHouseByHouseId&houseId="+escape(document.forms[0].houseId.value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}

	function callback() {
		if (4 == req.readyState) {
			if (200 == req.status) {
				//如果响应成功，读取响应数据
				var info = req.responseText;
				document.getElementById("errorSpan").innerHTML=info;
				document.getElementById("noticeSpan").style.display="none";
			}
		}
	}

	function checkForm() {
		var houseId = document.forms[0].houseId.value;
		var amounts = document.forms[0].amount;
		
		if (houseId == null || houseId == "") {
			alert("请输入房产编号！");
			return false;
		} else if (houseId.length!=11) {
			alert("请输入11位房产编号！");
			return false;
		}
		var count = 0;
		for(var i=0;i<amounts.length;i++) {
			if (amounts[i].value != 0) {
				count++;
			}
		}
		if(count==0) {
			alert("请输入欠费金额");
			return false;
		}			
		return true;
	}
</script>
</head>

<body>
<html:form action="historyDebtInput.do?method=save" method="post" onsubmit="return checkForm();">
  <table align="center" width="80%" border="0">
    <tr>
      <td class="STYLE4" align="center" bgcolor="#ffffff" colspan="2" height="40">房产历史欠费信息录入</td>
    </tr>
    <tr><td>
    <table align="center" class="tableline" cellspacing="1" cellpadding="0" width="80%" border="0">
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">房产编号:</td>
      <td width="773" bgcolor="#ffffff">
      &nbsp;<html:text property="houseId" onblur="findHouseByHouseId();"/><span id="noticeSpan" style="color:#5f9c12;">&nbsp;&nbsp;请输入11位数字，例如02030110001</span>
      &nbsp;<span id="errorSpan" style="color:red"></span>
	  </td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">物业服务费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入物业服务费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">电费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入电费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">水费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入水费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">停车服务费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入停车服务费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">垃圾清运费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入垃圾清运费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">路灯电费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入路灯电费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>
    <tr>
      <td width="217" height="26" align="right" bgcolor="#ffffff">二次提水电费欠费:</td>
      <td bgcolor="#ffffff">&nbsp;<html:text property="amount" />&nbsp;&nbsp;<span style="color:#5f9c12;">请输入二次提水电费历史欠费金额，单位(元)</span><font color="red">${amountError }</font></td>
    </tr>    
    <tr>
      <td height="26" colspan="2" align="center" bgcolor="#ffffff"><html:submit value="保存历史欠费信息" />&nbsp;&nbsp;<html:reset value="清空历史欠费信息" /><span style="color:red">${houseNotFoundError }</span></td>
      </tr>
    </table>
    </td></tr>
  </table>
  </html:form>
</body>
</html>